/*
 * @(#)EcCommodityServiceImpl.java
 *
 * Copyright 2011 Xinhua Online, Inc. All rights reserved.
 */

package com.winxuan.channel.service.commodity.impl;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.stereotype.Service;

import com.winxuan.channel.service.commodity.EcCommodityService;

/**
 * description
 * @author  HideHai
 * @version 1.0,2011-6-20
 */
@Service("ecCommodityService")
public class EcCommodityServiceImpl implements EcCommodityService{

	@Autowired
	private JdbcTemplate jdbcTemplateOracle;

	private static final String SELECT_GOODSNO_SQL = "SELECT GOODS_ID FROM TBL_SHOP_GOODS TSG WHERE SHOP_NO =1 " +
	"AND TSG.GOODS_NO =?";

	@Override
	public Integer getGoodsNoByShopNo(Integer shopNo) {
		Integer goodsNo = jdbcTemplateOracle.query(SELECT_GOODSNO_SQL, new Object[]{shopNo}, new ResultSetExtractor<Integer>() {

			@Override
			public Integer extractData(ResultSet rs) throws SQLException,
			DataAccessException {
				if(rs.next()){
					return rs.getInt("GOODS_ID");
				}
				return null;
			}
		});
		return goodsNo;
	}

}

